<?php
// $Id$

/**
 * Controller_Admin_Product 控制器
 */
class Controller_Admin_Product extends Controller_Abstract
{

	function actionIndex()
	{
        // 为 $this->_view 指定的值将会传递数据到视图中
		# $this->_view['text'] = 'Hello!';
	}
	function actionadd()
	{
		$this->union_table = Product::meta();
		$handle = new helper_autoinsert($this->union_table);
		$form = new Form_product(url($this->_context->controller_name.'/'.$this->_context->action_name));
		$result = $handle->add($form, 'id',$_GET);
		
		if ($this->_context->isGET())
		{
			//列出下级代理
			//dump($this->productIni['yt']);die;
			//$sub_agentArray = Acct::find($this->_format_appendSql())->setColumns('id,acctname')->asArray()->getAll();
			//	$sub_agentArray = Helper_Array::toHashmap($sub_agentArray, 'id','acctname');
			$result->element('type')->items = Categorys::get_category_tree('2');
			$result->element('zhonglei')->items = $this->productIni['zl'];
			$result->element('expday')->items = $this->productIni['expday'];
			$result->element('lilv')->items = $this->productIni['lilv'];
			$result->element('retype')->items = $this->productIni['retype'];
			$result->element('yongtu')->items = array_unique(array_merge($this->productIni['yt']['个人'],$this->productIni['yt']['企业']));
			$this->_view['form'] = $result;
			$this->_viewname = '../form/add';
				
		}else {
			return call_user_func_array(array($this,$handle->status),array($result));
		}

	}
	function actionlist()
	{
		$this->union_table = Product::meta();
		$this->lists();
	}
	function actiondel()
	{
		$this->union_table = Product::meta();
		$this->delete(array('id'=>$this->_context->ids));
	}

}
